#ifndef __RINGBUFFER_H__
#define __RINGBUFFER_H__
#include "basictype.h"

//能存储的有效字节数=(end-start+1)-1;
typedef struct {
  UINT8 *start;
  UINT8 *end;
  UINT8 *lr;
  UINT8 *wr;
} RingBuffer_t;

extern void *RingBuffer_Init(RingBuffer_t *ringBuf, UINT8 *buf, UINT32 bufSize);
extern INT32 RingBuffer_Size(RingBuffer_t *ringBuf);
extern INT32 RingBuffer_DataLen(RingBuffer_t *ringBuf);
extern INT32 RingBuffer_SpaceLen(RingBuffer_t *ringBuf);
extern INT32 RingBuffer_Read(RingBuffer_t *ringBuf, UINT8 *buf, INT32 toReadSize);

extern INT32 RingBuffer_Peek(RingBuffer_t *ringBuf, UINT8 *buf, INT32 peekSize);

extern INT32 RingBuffer_Write(RingBuffer_t *ringBuf, UINT8 *buf, INT32 toWriteSize);

extern void RingBuffer_Reset(RingBuffer_t *ringBuf);

#endif